import 'es6-promise/auto'
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({

    state: {
        Root :{
            id: window.localStorage.getItem("id"),
            isRoot: 0,
            stop: 0,
        }
    },

    getters: {
        // 获取当前Root
        getRoot(state){
            return state.Root;
        },
        // 获取Root.stop
        getStop(state){
            return state.Root.stop
        },
      },

    mutations: {
    //  设置当前用户的登录权限
        // setRoot(state , root ,id){
        //     console.log("id:" +id)
        //     state.Root.id = id;
        //     state.Root.isRoot = root;
        // }
        setRoot(state , root){
            state.Root.isRoot = root;
        },
        setRootStop(state , stop){
            state.Root.stop = stop;
        }
    }
  })

  export default store